# encoding=utf-8
from LBT.BaseParent.BaseLbt import lbtlogin
from LBT.Resource.StudentAttendance.StudentAttendanceAtt import StudentAttendanceAtt
from LBT.GeneralOperation.StudentOperation import StudentOperation


class ClassAttendance(lbtlogin, StudentAttendanceAtt):
    '''考勤设置模块
    1、一天两次，设置8：30--10:30，16：00--18:00然后改成四次8：30--10:30，11:30--1230,1430-1530，16：00--18:00
    '''

    @lbtlogin.loginFun
    def test_stuattconfig(self):
        """
        一天两次，设置8：30--10:30，16：00--18:00然后改成四次8：30--10:30，11:30--1230,1430-1530，16：00--18:00
        :return:
        """
        self.docstr = '一天两次，然后改成四次'
        dr = self.driver
        self.moduleOp.openMoudleAndIn(self.studentatten_navigation_class, self.studentatten_set_url,
                                      self.student_topnavigation_class)
        # 改成一天两次，然后数据库核对
        dr.find_element_by_xpath(self.stuattcon_2card_xpath).click()
        onetime='08:30 - 10:30'
        pmtwotime='16:00 - 18:00'
        #dr.find_element_by_id(self.stuattcon_1time_id).send_keys(onetime)
        self.clearAndSendKeyForText(dr.find_element_by_id(self.stuattcon_1time_id),onetime)
        self.clearAndSendKeyForText(dr.find_element_by_id(self.stuattcon_4time_id),pmtwotime)
        dr.find_element_by_css_selector(self.classatt_selectbtn_css).click()
        sql="select onecardbegintime"+"+' - '+"+"onecardendtime,twocardbegintime"+"+' - '+"+"twocardendtime, pmonecardbegintime"+"+' - '+"+"pmonecardendtime,pmtwocardbegintime"+"+' - '+"+"pmtwocardendtime from c_safetymachineconfig where schoolid = (select schoolid from school where schoolname like '"+self.lbt_schoolname_text+"') and enddate is null"
        result=self.selectlbtmutilcolumn(sql)
        self.assertEqual(str(result[0][0]),onetime)
        self.assertEqual(str(result[0][3]), pmtwotime)
        # 改成一天4次，然后数据库核对
        onetime = '08:31 - 10:31'
        twotime = '11:30 - 12:30'
        pmonetime = '14:30 - 15:30'
        pmtwotime = '16:01 - 18:01'
        dr.find_element_by_xpath(self.stuattcon_4card_xpath).click()
        self.clearAndSendKeyForText(dr.find_element_by_id(self.stuattcon_1time_id),onetime)
        self.clearAndSendKeyForText(dr.find_element_by_id(self.stuattcon_2time_id),twotime)
        self.clearAndSendKeyForText(dr.find_element_by_id(self.stuattcon_3time_id),pmonetime)
        self.clearAndSendKeyForText(dr.find_element_by_id(self.stuattcon_4time_id),pmtwotime)
        dr.find_element_by_css_selector(self.classatt_selectbtn_css).click()
        sql = "select onecardbegintime" + "+' - '+" + "onecardendtime,twocardbegintime" + "+' - '+" + "twocardendtime, pmonecardbegintime" + "+' - '+" + "pmonecardendtime,pmtwocardbegintime" + "+' - '+" + "pmtwocardendtime from c_safetymachineconfig where schoolid = (select schoolid from school where schoolname like '" + self.lbt_schoolname_text + "') and enddate is null"
        result = self.selectlbtmutilcolumn(sql)
        self.assertEqual(str(result[0][0]), onetime)
        self.assertEqual(str(result[0][1]), twotime)
        self.assertEqual(str(result[0][2]), pmonetime)
        self.assertEqual(str(result[0][3]), pmtwotime)
